package com.yckj.day07;

/**
 * TODO
 *
 * @author shengyuee
 * @version 1.0
 * 2025/7/24 14:27
 */
public class Student1 extends Person{
    String name = "wangwu";
    private String sid;
    private String cname;
    private double weight;

    public Student1() {
        super(); // 默认调用父类的构造方法
        System.out.println("子类构造方法");
    }

    public Student1(String name){
        super("zhangsan"); // 指定调用父类的带一个参数的构造方法，必须在第一行
//        this();// 调用本类的构造方法，它也要在第一行，super()与this()不能同时使用
        System.out.println("子类有参构造方法");
        this.name = name;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }
    public void show(){
        System.out.println(this.name);// 访问当前的成员变量，this可以省略
        System.out.println(super.name); // 访问父类的成员变量
    }
}
